<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="functions.asp" -->
<%

dim sql

'update exireg
'  	sql = "UPDATE EXIREG SET "
'	sql = sql & " ISOPEN='Y'" 
'	sql = sql & " WHERE SEQNUM=" & request.querystring("seqnum")

'	cn.execute(sql)

Dim EXIREG__tmpNum
EXIREG__tmpNum = "0"
if (request.querystring("seqnum") <> "") then EXIREG__tmpNum = request.querystring("seqnum")
%>
<%
set EXIREG = Server.CreateObject("ADODB.Recordset")
EXIREG.ActiveConnection = cn
EXIREG.Source = "SELECT SEQNUM, REGNUM, INVNUM, EMPCODE,VENDORID, PONUM,INVSTATUS, MULTIVERIFY,REFORDER,USERCOORD,INVAMOUNT,INVCURRENCY, (SELECT EXCHANGERATE FROM EXCHRATE WHERE EXCHRATE.MP2CURRENCY=EXIREG.INVCURRENCY) AS FRATE, CURRENCYSYMBOL, VERIFIEDBY, VERIFIEDSTATUS,DEPARTMENT, AUTHORISEDBY, LOCATION, APPROVEDBY,APPROVED2BY,JOINAPPROVAL,INVRECDATE, INVDUEDATE, DATEVERIFIED,DATEAUTHORISED,DATEAPPROVED,DATEAPPROVED2,REFERENCEDOC, (SELECT TOP 1  VENDOR.NAME FROM VENDOR WHERE VENDOR.VENDORID=EXIREG.VENDORID) AS VENDORNAME, "_
 & "(SELECT VERNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.VERIFIEDBY) AS VERNAME,"_
 & "(SELECT AUTHNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.AUTHORISEDBY) AS AUTHNAME,"_
 & "(SELECT APPRNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.APPROVEDBY) AS APPRNAME,"_
 & "(SELECT APPRNAME2=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.APPROVED2BY) AS APPRNAME2,"_
 & "(SELECT LOCNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.LOCATION) AS LOCNAME,"_
&"USERDEPT,COMMENTS  FROM dbo.EXIREG  WHERE SEQNUM=" + Replace(EXIREG__tmpNum, "'", "''") + "  "
'EXIREG.CursorType = 0
'EXIREG.CursorLocation = 2
'EXIREG.LockType = 3
EXIREG.Open()
EXIREG_numRows = 0
dim PO
PO=EXIREG.Fields.Item("PONUM").Value
dim Inv
Inv=EXIREG.Fields.Item("INVNUM").Value
%>
<%
Dim InvHist__tmpNum
InvHist__tmpNum = "0"
if (Request.Querystring("seqnum") <> "") then InvHist__tmpNum = Request.Querystring("seqnum")
%>
<%
set InvHist = Server.CreateObject("ADODB.Recordset")
InvHist.ActiveConnection = cn
InvHist.Source = "SELECT *,  (SELECT TRDESCR FROM EXITRTYPE WHERE EXIHIST.TRANSTYPE=EXITRTYPE.TRTYPE) AS TRDESCR,   (SELECT EMP.FIRSTNAME + ' '  + EMP.LASTNAME FROM dbo.EMP WHERE EMP.EMPCODE=EXIHIST.LOCATION) AS LOCNAME  FROM dbo.EXIHIST  WHERE SEQNUM=" + Replace(InvHist__tmpNum, "'", "''") + " ORDER BY UPDATESTAMP ASC"
'InvHist.CursorType = 0
'InvHist.CursorLocation = 2
'InvHist.LockType = 3
InvHist.Open()
InvHist_numRows = 0
%>
<%
set CompCode = Server.CreateObject("ADODB.Recordset")
CompCode.ActiveConnection = cn
CompCode.Source = "SELECT *  FROM dbo.COMPCODE"
'CompCode.CursorType = 0
'CompCode.CursorLocation = 2
'CompCode.LockType = 3
CompCode.Open()
CompCode_numRows = 0
%>
<%
Dim Acct__tmpNum
Acct__tmpNum = "0"
if (Request.querystring("seqnum")  <> "") then Acct__tmpNum = Request.querystring("seqnum") 
%>
<%
set Acct = Server.CreateObject("ADODB.Recordset")
Acct.ActiveConnection = cn
Acct.Source = "SELECT *  FROM dbo.EXICHARGE  WHERE INVSEQNUM=" + Replace(Acct__tmpNum, "'", "''") + ""
'Acct.CursorType = 0
'Acct.CursorLocation = 2
'Acct.LockType = 3
Acct.Open()
Acct_numRows = 0
%>
<%
Dim Verification__tmpNum
Verification__tmpNum = "0"
if (Request.QueryString("seqnum") <> "") then Verification__tmpNum = Request.QueryString("seqnum")
%>
<%
set Verification = Server.CreateObject("ADODB.Recordset")
Verification.ActiveConnection = cn
Verification.Source = "SELECT *  FROM dbo.EXIVERIFY  WHERE INVSEQNUM=" + Replace(Verification__tmpNum, "'", "''") + ""
'Verification.CursorType = 0
'Verification.CursorLocation = 2
'Verification.LockType = 3
Verification.Open()
Verification_numRows = 0
%>
<%
Dim Receipt__tmpNum
Receipt__tmpNum = "''"
if (PONUM <> "") then Receipt__tmpNum = EXIREG.Fields.Item("PONUM").Value
%>
<%
Dim Receipt__tmpInv
Receipt__tmpInv = "''"
if (INVNUM <> "") then Receipt__tmpInv = EXIREG.Fields.Item("INVNUM").Value
%>
<%
'SELECT RECEIVERNUM, INVOICENUM, INVOICEDATE,INVOICESTATUS, PONUM, QTYRECEIVED, DATERECEIVED, UNITCOST, LINECOST  FROM dbo.PORECEIV  WHERE PONUM = '" + Replace(Receipt__tmpNum, "'", "''") + "'  AND INVOICENUM = '" + Replace(Receipt__tmpInv, "'", "''") + "'"
set Receipt = Server.CreateObject("ADODB.Recordset")
Receipt.ActiveConnection = cn
Receipt.Source = "SELECT RECEIVERNUM, INVOICENUM, INVOICEDATE,INVOICESTATUS, PONUM, QTYRECEIVED, DATERECEIVED, UNITCOST, LINECOST  FROM dbo.PORECEIV  WHERE PONUM = '" &PO& "'  AND INVOICENUM = '" & Inv & "'"
'Receipt.CursorType = 0
'Receipt.CursorLocation = 2
'Receipt.LockType = 3
Receipt.Open()
Receipt_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
InvHist_numRows = InvHist_numRows + Repeat1__numRows
%>
<%
Dim Repeat4__numRows
Repeat4__numRows = -1
Dim Repeat4__index
Repeat4__index = 0
Receipt_numRows = Receipt_numRows + Repeat4__numRows
%>
<%
Dim Repeat3__numRows
Repeat3__numRows = -1
Dim Repeat3__index
Repeat3__index = 0
Verification_numRows = Verification_numRows + Repeat3__numRows
%>
<%
Dim Repeat2__numRows
Repeat2__numRows = -1
Dim Repeat2__index
Repeat2__index = 0
Acct_numRows = Acct_numRows + Repeat2__numRows
%>
<%
dim isUser
dim isAuthorised
dim isOutLimit
dim btnCaption
dim btnCaption2
dim TrType
dim Caption1
dim Caption2
dim Verseqnum
dim btnVisible
verseqnum=0
btnCaption2="Reject Invoice"

if (EXIREG.Fields.Item("USERCOORD").Value <> "") then
btnVisible=isUC
else
btnVisible="Y"
end if

Function get_Authorise(e)
'if (EXIREG.Fields.Item("APPROVEDBY").Value <> "") then
 sql = "SELECT  A.GROUPDESC, A.EMPCODE, B.CURRENCY, B.INVAMTPO, B.INVAMTNONPO"
 sql = sql & " FROM dbo.EXIAUTHORITY A, dbo.EXIAUTHFINANCE B"
 sql = sql & " WHERE A.GROUPDESC=B.GROUPDESC "
 sql = sql & " AND A.EMPCODE = '" & e & "'"
 set rs = cn.execute(sql)
 
do while not rs.eof
 if (EXIREG.Fields.Item("REFORDER").Value = "Y") then
   if ((EXIREG.Fields.Item("INVAMOUNT").Value/EXIREG.Fields.Item("FRATE").Value) > rs("INVAMTPO")) then
     get_Authorise = "N"
   else
     get_Authorise = "Y"
   end if
 else
   if ((EXIREG.Fields.Item("INVAMOUNT").Value/EXIREG.Fields.Item("FRATE").Value) > rs("INVAMTNONPO")) then
     get_Authorise = "N"
   else
     get_Authorise = "Y"
   end if
 end if
 
rs.movenext
loop
set rs = nothing
'end if

end function

if (isUC="Y") then
 btnCaption = " Route Invoice "
 TrType = "Route"
 if (EXIREG.Fields.Item("INVSTATUS").Value ="REJECTED") then
 btnCaption2 = "Route Back to Finance"
 end if
end if

if (empCode = EXIREG.Fields.Item("VERIFIEDBY").Value) then
 btnCaption = " Verify Invoice "
 TrType = "Verify"
end if

if (EXIREG.Fields.Item("APPROVEDBY").Value<>"")then
isAuthorised=get_Authorise(EXIREG.Fields.Item("APPROVEDBY").Value)
end if
if (EXIREG.Fields.Item("APPROVEDBY").Value=empCode)then
 if (isAuthorised = "Y") then   
   btnCaption = " Approve Invoice "
   TrType = "Approve"
 else
   TrType = "PreApprove"
   btnCaption = " Approve Invoice "
 end if
end if

if (EXIREG.Fields.Item("APPROVED2BY").Value<>"")then
isAuthorised=get_Authorise(EXIREG.Fields.Item("APPROVED2BY").Value)
end if

if (EXIREG.Fields.Item("APPROVED2BY").Value=empCode)then
 if (isAuthorised = "Y") then  
   btnCaption = " Approve Invoice "
   TrType = "Approve2"
 else
   TrType = "PreApprove2"
   btnCaption = " Approve Invoice "
 end if
end if

if (empCode = EXIREG.Fields.Item("AUTHORISEDBY").Value ) then
   btnCaption = " Approve Invoice "
   TrType = "Approve"
   'isAuthorised = "N"
end if

if (EXIREG.Fields.Item("MULTIVERIFY").Value="Y" ) then
  sql = "SELECT *  FROM EXIVERIFY WHERE INVSEQNUM=" & request.querystring("seqnum")
  sql = sql & " AND VERIFIEDBY='" & empCode & "'"
  sql = sql & " AND VERIFYSTATUS='NOT VERIFY'"
  set rs = cn.execute(sql)
  Do while not rs.eof 
    btnCaption = " Verify Invoice "
    TrType = "MultiVerify"
	VerSeqnum = rs("SEQNUM")
  rs.movenext
  loop
end if

if(EXIREG.Fields.Item("JOINAPPROVAL").Value="Y") then
  caption1="Approved 1 By:"
  caption2="Approved 2 By:"
else
  caption1="Approved By:"
end if

%>
<SCRIPT Language = "JavaScript">

function Valid_Charge(x,y)
{
  var dtTotal=y;
  var totalValue =  Number(document.form1.Amt1.value) + Number(document.form1.Amt2.value)+Number(document.form1.Amt3.value) +Number(document.form1.Amt4.value)+ Number(document.form1.Amt5.value);
   
   if (totalValue > dtTotal ){
     alert("Total amount is greater than invoice amount!");
     x.focus();
	 x.value=0;
     return false;
	 }
}

function DocLoad(){
var multiver='<%=(EXIREG.Fields.Item("MULTIVERIFY").Value)%>';
var joinAppr='<%=(EXIREG.Fields.Item("JOINAPPROVAL").Value)%>';
var isUC='<%= isUC %>';
var isAuthorised='<%= isAuthorised %>';
document.getElementById("inv_hist").style.display='none';
if (multiver=='N'){
  document.getElementById("userVer").style.display='none';
  document.getElementById("usrTable").style.display='none';
  }
if (joinAppr=='N'){
  document.getElementById("Approved2").style.display='none';
  }
if (isAuthorised=='N'){
  document.getElementById("Authorise").style.display='block';
  }
else
  {
  document.getElementById("Authorise").style.display='none';
  }
}

function Reject_Inv(){
		window.location = 'Reject_Inv.asp?RecBy=<%=(EXIREG.Fields.Item("EMPCODE").Value)%>&UC=<%=(EXIREG.Fields.Item("USERCOORD").Value)%>&isUC=<%= isUC %>&seqnum=<%=(EXIREG.Fields.Item("SEQNUM").Value)%>&VendorName=<%=(EXIREG.Fields.Item("VENDORNAME").Value)%>&InvoiceNo=<%=(EXIREG.Fields.Item("INVNUM").Value)%>'
		} 

function NotifyUser(){
        var empCode='<%= empCode %>'; 
		var invStatus='<%=(EXIREG.Fields.Item("INVSTATUS").Value)%>';
		var status=document.form1.status.value;
if ((status=="REJECTED")||(invStatus=='APPROVED')){
 alert("Cannot send notification, invoice already rejected or approved!");
 return false;
}
else
{
        if (empCode=='<%=(EXIREG.Fields.Item("LOCATION").Value)%>'){
		alert('Cannot send notification to yourself!');
		return false;
		}
		else{
		window.location = 'Send_notification.asp?isUC=Y&Loc=<%=(EXIREG.Fields.Item("LOCATION").Value)%>&LocName=<%=(EXIREG.Fields.Item("LOCNAME").Value)%>&seqnum=<%=(EXIREG.Fields.Item("SEQNUM").Value)%>&VendorName=<%=(EXIREG.Fields.Item("VENDORNAME").Value)%>&InvoiceNo=<%=(EXIREG.Fields.Item("INVNUM").Value)%>' 
  }
}
}



function displayTbl(cb)
{var e=cb.value;
 var myRow1=document.getElementById("userVer");
 var myRow2=document.getElementById("usrTable");
 if (e=='Y') {
    if (myRow1.style.display=='none')
	   {
	   myRow1.style.display='block'; }
	else
	    {
	   myRow1.style.display='none'; }
	if( myRow2.style.display=='none')
	   {
	   myRow2.style.display='block';}
	else
	   {
	   myRow2.style.display='none';}
	}
 else
   {
    myRow1.style.display='none';
	myRow2.style.display='none';
	}
    //document.getElementById("userVer").getElementsByTagName("TBODY")[0].visible=false;
}

function ShowAppr(cb2)
{ var e2=cb2.value;
  var rowAppr=document.getElementById("Approved2");
  var txt1=document.getElementById("caption1");
  var txt2=document.getElementById("caption2");
  if (e2=='Y') {
    if (rowAppr.style.display=='none')
	   {rowAppr.style.display='block';
	   txt1.innerHTML='Approved 1 By: ';
	   txt1.style.fontWeight = "bold";
	   txt2.innerHTML='Approved 2 By: ';
	   txt2.style.fontWeight = "bold";}
	else 
	   { rowAppr.style.display='none';
	     txt1.innerHTML='Approved By: ';
		fontWeight = "bold";}
  }
  else
  {rowAppr.style.display='none';}
}

function show_hist(dfield){
//var txt=document.getElementById("caption3");
//if (dfield.checked) {
//document.getElementById("inv_hist").style.display='block';
//txt.innerHTML='Hide History';
//} 
//else {
//document.getElementById("inv_hist").style.display='none';
//txt.innerHTML='View History';}
if (document.getElementById("inv_hist").style.display=='none'){
document.getElementById("inv_hist").style.display='block';
dfield.value=' Hide History ';
} 
else {
document.getElementById("inv_hist").style.display='none';
dfield.value=' View History ';}
}

function Valid_DOA(x,y)
{
  var Amt_PO=x;
  var Amt_nonPO=y;
  var Ex_rate= <%=EXIREG.Fields.Item("FRATE").Value %>;
  var Inv_Amt= <%= EXIREG.Fields.Item("INVAMOUNT").Value %>;
  var Ref='<%= EXIREG.Fields.Item("REFORDER").Value %>';
  if (Ref=='Y') {
    if ((Inv_Amt/Ex_rate)>Amt_PO){
	  document.getElementById("Authorise").style.display='block';
	 
    }
	else
	{
	  document.getElementById("Authorise").style.display='none';
	 
    }
  }
  else
  {
    if ((Inv_Amt/Ex_rate)>Amt_nonPO){
	  document.getElementById("Authorise").style.display='block';
	  
    }
	else
	{
	  document.getElementById("Authorise").style.display='none';
	  
    }
  }
  
}

function formSubmit(which) { 
var pass=true;
var status=document.form1.status.value;
var isUC='<%= isUC %>';
if ((status=="REJECTED")&&(isUC=="N")){
 alert("Cannot edit REJECTED invoice!");
 return false;
}
else
{
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,3)=="req") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(3,30).toUpperCase();
alert("Please make sure the " + shortFieldName + " field was properly completed.");
return false;
}
else
  {
  
  if ((document.form1.hf.value == "a")||(document.form1.hf.value == "b")){ 
  document.form1.action= "My_InvProcess.asp"; 
  } 
  if (document.form1.hf.value == "c")   { 
  document.form1.action= "Reject_Inv.asp"; 
  } 
  return true;
  }
}
} 

function validate_charge(a,b,c,src)
{var y=b.value;
 if (y!="") {
window.open("ValCharge.asp?T0="+a+"&T1="+y+"&T2="+c+"&src="+src,"","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else src.value="";
}
function validate_charge2(a,b,c,src)
{var y=c.value;
 if (y!="") {
window.open("ValCharge.asp?T0="+a+"&T1="+b+"&T2="+y+"&src="+src,"","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else src.value="";
}

var InvNum='<%= request.querystring("InvNum") %>';
var InvStatus='<%= request.querystring("InvStatus") %>';
var dsort='<%= request.querystring("dsort") %>';
var dorder='<%= request.querystring("dorder") %>';
var RefOrder='<%= request.querystring("refOrder") %>';
var VendorID='<%= request.querystring("VendorID") %>';
var CurSymbol='<%= request.querystring("CurSymbol") %>';
var RecDate='<%= request.querystring("RecDate") %>';
var RecDate2='<%= request.querystring("RecDate2") %>';
var RptCond='<%= request.querystring("RptCond") %>';

//function DocLoad(){
//document.form1.reqInvoiceNo.focus();
//}

function redirect1(){
location='My_Invoice_List.asp?InvNum='+InvNum+'&InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}

function redirect2(){
location='My_Invoice.asp?InvNum='+InvNum+'&InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}
function register(){
location='Inv_Register.asp?InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}
</SCRIPT>
<!-- #include file="pagetop_usr.asp" -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td nowrap height="21" bgcolor="#FFFFFF" width="3%" background="images/menu_end.gif">&nbsp;</td>
    <td nowrap height="21" bgcolor="#FFFFFF" width="28"> 
      <div align="center"><img src="images/menu_awal_off.gif" width="28" height="33"></div>
    </td>
    <td width="15%" background="images/menuoff.gif" height="21" nowrap> 
      <div align="center"><b><a href="#" class="menu" onClick="return redirect2()">My 
        Invoice</a></b></div>
    </td>
    <td nowrap height="21" width="28"><img src="images/menu_off_off_separator.gif" width="28" height="33"></td>
    <td nowrap height="21" width="15%" background="images/menuoff.gif"> 
      <div align="center"><a href="#" class="menu" onClick="return redirect1()">My 
        Invoice Archive</a></div>
    </td>
    <td nowrap height="21" width="28"><img src="images/menu_off_on_separator.gif" width="28" height="33"></td>
    <td width="15%" background="images/menuon.gif" height="21" nowrap> 
      <div align="center" class="menu">Invoice Detail </div>
    </td>
    <td height="21" bgcolor="#FFFFFF" width="11"><img src="images/Menu_onend.gif" width="13" height="33"></td>
    <td height="21" bgcolor="#FFFFFF" background="images/menu_end.gif"> 
      <div align="right"></div>
    </td>
  </tr>
  <tr bgcolor="#93bee2"> 
    <td height="21" width="3%" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="10%" height="21" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28">&nbsp;</td>
    <td height="21" width="28">&nbsp;</td>
    <td height="21" width="28">&nbsp;</td>
    <td width="10%" height="21">&nbsp;</td>
    <td height="21">&nbsp;</td>
    <td height="21">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#93bee2">
  <tr> 
    <td width="4%" height="14">&nbsp;</td>
    <td width="2%" height="14">&nbsp;</td>
    <td width="94%" height="14">&nbsp; </td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td width="94%">&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF"><img src="images/curv_data.gif" width="21" height="21"></td>
    <td bgcolor="#FFFFFF" width="94%"></td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF" width="94%"> 
      <form name="form1" method="post" action="" onSubmit="return formSubmit(this);">
        <table width="100%" border="0" cellspacing="2" cellpadding="3">
          <tbody> 
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Invoice No.:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"> <%=(EXIREG.Fields.Item("INVNUM").Value)%> 
              <input type="hidden" name="seqnum" value="<%=(EXIREG.Fields.Item("SEQNUM").Value)%>">
            </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Invoice Status:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25" width="36%"> <b><%=(EXIREG.Fields.Item("INVSTATUS").Value)%> </b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="24"> 
              <div align="right"><b>Register No.:&nbsp;</b></div>
            </td>
            <td width="2%" height="24">&nbsp;</td>
            <td width="30%" height="24"><%=(EXIREG.Fields.Item("REGNUM").Value)%></td>
            <td width="15%" bgcolor="#dedede" height="24"> 
              <div align="right"><b>Current Location:&nbsp;</b></div>
            </td>
            <td width="2%" height="24">&nbsp;</td>
            <td bgcolor="#FFFFFF" height="24" width="36%"><b><font color="#990000"> 
              <% if (EXIREG.Fields.Item("LOCATION").Value="FINANCE") then %>
              FINANCE 
              <% else %>
              <%=(EXIREG.Fields.Item("LOCNAME").Value)%> 
              <% end if %>
              </font></b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Reference Order:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"><%=(EXIREG.Fields.Item("PONUM").Value)%> </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Department:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td bgcolor="#FFFFFF" height="25" width="36%"><%=(EXIREG.Fields.Item("USERDEPT").Value)%> </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Vendor:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"> <%=(EXIREG.Fields.Item("VENDORID").Value)%>&nbsp;&nbsp;&nbsp;<%=(EXIREG.Fields.Item("VENDORNAME").Value)%></td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Received Date:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td bgcolor="#FFFFFF" height="25" width="36%"><%=(DoDateTime((EXIREG.Fields.Item("INVRECDATE").Value), 1, 2057))%></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Invoice Amount:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"><b><%=(EXIREG.Fields.Item("CURRENCYSYMBOL").Value)%>&nbsp;&nbsp;<%= FormatNumber((EXIREG.Fields.Item("INVAMOUNT").Value), -1, -2, -2, -1) %></b></td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b> Due Date:</b>&nbsp;</div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25" width="36%"><%= DoDateTime((EXIREG.Fields.Item("INVDUEDATE").Value), 1, 2057) %> </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Original Invoice:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td colspan="4" height="25"><a href="javascript:opennew('<%=(EXIREG.Fields.Item("REFERENCEDOC").Value)%>')"><%=(EXIREG.Fields.Item("REFERENCEDOC").Value)%></a> </td>
          </tr>
          <tr id="userVer" > 
            <td width="15%" valign="top"></td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="4" valign="middle"><b>Approval &amp; Verification:</b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" valign="middle"> 
              <div align="right"><b>Verified By: 1. &nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="4" valign="middle"> <%=(EXIREG.Fields.Item("VERNAME").Value)%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG.Fields.Item("VERIFIEDSTATUS").Value="VERIFIED") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified 
              <% end if %>
              <input type="hidden" name="Dept" size="15" class="InputBox" value="<%=(EXIREG.Fields.Item("USERDEPT").Value)%>">
            </td>
          </tr>
          <% Incr = 1  
				do while not Verification.EOF %>
          <tr id="userVer<%= incr %>" > 
            <td width="15%" valign="middle" bgcolor="#efefef"> 
              <div align="right"><b><%= incr + 1 %>.&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <input type="hidden" name="Ver<%= Incr %>" size="10" class="InputBox" value="<%=(Verification("VERIFIEDBY"))%>">
              <input type="text" name="VerName<%= Incr %>" size="30" class="GridBox" value="<%=(Verification("VERNAME"))%>">
              &nbsp; 
              <% if (Verification("VERIFYSTATUS")="VERIFIED") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified 
              &nbsp;&nbsp;<%= DoDateTime((Verification("DATEVERIFIED")), 2, 2070) %> 
              <% end if %>
            </td>
          </tr>
          <% Incr = Incr + 1
                  Verification.MoveNext
                  loop %>
          <tr> 
            <td width="15%" bgcolor="#dedede" valign="middle"> 
              <div align="right" id="caption1"><b><%= caption1 %>&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="4" valign="middle"> <%=(EXIREG.Fields.Item("APPRNAME").Value)%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG.Fields.Item("DATEAPPROVED").Value<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Approved 
              <% end if %>
              <input type="hidden" name="InvAmtNonPo">
              <input type="hidden" name="InvAmtPo">
            </td>
          </tr>
          <tr id="Approved2"> 
            <td width="15%" bgcolor="#dedede" valign="middle"> 
              <div align="right" id="caption2"><b><%= caption2 %>&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="4" valign="middle"> <%=(EXIREG.Fields.Item("APPRNAME2").Value)%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG.Fields.Item("DATEAPPROVED2").Value<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Approved 
              <% end if %>
              <input type="hidden" name="InvAmtNonPo2">
              <input type="hidden" name="InvAmtPo2">
            </td>
          </tr>
          <% 'if (isAuthorised = "N")  then %>
          <tr id="Authorise"> 
            <td width="15%" bgcolor="#dedede" valign="middle"> 
              <div align="right"><b>Authorised By:</b>&nbsp;</div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="4" valign="middle"> <%=(EXIREG.Fields.Item("AUTHNAME").Value)%> &nbsp;&nbsp; 
              <% if (EXIREG.Fields.Item("DATEAUTHORISED").Value<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Authorised 
              <% end if %>
              <input type="hidden" name="InvAmtPo3">
              <input type="hidden" name="InvAmtNonPo3">
            </td>
          </tr>
          <%' end if %>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="30"> 
              <div align="right"><b>Comments:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <textarea name="textfield" cols="80" rows="5" class="InputBoxCopy" readonly="true"><%=(EXIREG.Fields.Item("COMMENTS").Value)%></textarea>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF" height="18">&nbsp;</td>
            <td width="2%" height="18">&nbsp;</td>
            <td colspan="4" height="18"><font color="#000000"><b>Allocation: </b></font><font color="#FF0000" size="1"> 
              <input type="hidden" name="TrType" value="<%= TrType %>">
              <input type="hidden" name="status" value="<%=(EXIREG.Fields.Item("INVSTATUS").Value)%>">
              <input type="hidden" name="Authorised" value="<%= isAuthorised %>">
              <input type="hidden" name="isUC" value="<%= isUC %>">
              <input type="hidden" name="UC" value="<%=(EXIREG.Fields.Item("USERCOORD").Value)%>">
              <input type="hidden" name="recBy" value="<%=(EXIREG.Fields.Item("EMPCODE").Value)%>">
              </font> </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%"><font color="#003399"><b> </b></font></td>
            <td colspan="4"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999" id="Acct_tbl">
                <tr bgcolor="#FFC58A"> 
                  <td width="5%" height="21"> 
                    <div align="center"><b>No</b></div>
                  </td>
                  <td width="17%" height="21"> 
                    <div align="center"><b>Account Code</b></div>
                  </td>
                  <td width="10%" height="21"> 
                    <div align="center"><b>T0</b></div>
                  </td>
                  <td width="15%" height="21" bgcolor="#FFC58A"> 
                    <div align="center"><b>T1</b></div>
                  </td>
                  <td width="12%" height="21"> 
                    <div align="center"><b>T2</b></div>
                  </td>
                  <td width="18%" height="21"> 
                    <div align="center"><b>T3</b></div>
                  </td>
                  <td height="21"> 
                    <div align="center"><b>Amount (<%=(EXIREG.Fields.Item("CURRENCYSYMBOL").Value)%>)</b></div>
                  </td>
                </tr>
                <% dim Incr 
				Incr = 1 %>
                <% 
While ((Repeat2__numRows <> 0) AND (NOT Acct.EOF)) 
%>
                <tr> 
                  <td width="5%" bgcolor="#FFFFFF"> 
                    <div align="center"><%= Incr %>.</div>
                  </td>
                  <td width="17%" bgcolor="#FFFFFF"> 
                    <div align="center"> <%=(Acct.Fields.Item("ACCTCODE").Value)%> </div>
                  </td>
                  <td width="10%" bgcolor="#FFFFFF"> 
                    <div align="center"> <%=(Acct.Fields.Item("T0CODE").Value) %> </div>
                  </td>
                  <td width="15%" bgcolor="#FFFFFF"> 
                    <div align="center"> <%=(Acct.Fields.Item("T1CODE").Value)%> </div>
                  </td>
                  <td width="12%" bgcolor="#FFFFFF"> 
                    <div align="center"> <%=(Acct.Fields.Item("T2CODE").Value)%> </div>
                  </td>
                  <td width="18%" bgcolor="#FFFFFF"> 
                    <div align="center"> <%=(Acct.Fields.Item("T3CODE").Value)%> </div>
                  </td>
                  <td bgcolor="#FFFFFF"> 
                    <div align="right"><%=(Acct.Fields.Item("AMOUNT").Value)%> </div>
                  </td>
                </tr>
                <% Incr = Incr +1
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  Acct.MoveNext()
Wend
%>
              </table>
              <br>
              <input type="hidden" name="Incr" value="<%= Incr %>">
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="button" name="Submit4" value="View History" class="sbttn" onClick="show_hist(this)">
            </td>
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="36%">&nbsp;</td>
          </tr>
          <tr id="inv_hist"> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#999999">
                <tr bgcolor="#D1DDEF"> 
                  <td width="6%" height="25"> 
                    <div align="center"><b>No.</b></div>
                  </td>
                  <td width="15%" height="25"> 
                    <div align="center"><b>Date</b></div>
                  </td>
                  <td height="25" bgcolor="#D1DDEF"> 
                    <div align="center"><b>Description</b></div>
                  </td>
                  <td width="13%" bgcolor="#D1DDEF" height="25"> 
                    <div align="center"><b>Department</b></div>
                  </td>
                  <td width="13%" height="25"> 
                    <div align="center"><b>Update By</b></div>
                  </td>
                </tr>
                <%  Incr = 1 %>
                <% 
While ((Repeat1__numRows <> 0) AND (NOT InvHist.EOF)) 
%>
                <tr bgcolor="#FFFFFF"> 
                  <td width="6%"> 
                    <div align="center"><%= Incr %></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><%= DoDateTime((InvHist.Fields.Item("UPDATESTAMP").Value), 1, 2057) %></div>
                  </td>
                  <td><%=(InvHist.Fields.Item("TRDESCR").Value)%>&nbsp;<%=(InvHist.Fields.Item("LOCNAME").Value)%></td>
                  <td width="13%"><%=(InvHist.Fields.Item("DEPARTMENT").Value)%></td>
                  <td width="13%"><%=(InvHist.Fields.Item("UPDATEUSER").Value)%></td>
                </tr>
                <% 
  Incr = Incr + 1
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  InvHist.MoveNext()
Wend
%>
              </table>
            </td>
          </tr>
          <tr> 
            <td width="15%">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%">&nbsp;</td>
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="36%">&nbsp;</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Receipt:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#999999">
                <tr bgcolor="#D1DDEF"> 
                  <td width="6%"> 
                    <div align="center"><b>No.</b></div>
                  </td>
                  <td width="10%"> 
                    <div align="center"><b>Select</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Receiver No.</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Date Received</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Qty Received</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Unit Cost</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Line Cost</b></div>
                  </td>
                </tr>
                <% 
				   incr=1 %>
                <% 
While ((Repeat4__numRows <> 0) AND (NOT Receipt.EOF)) 
%>
                <tr bgcolor="#FFFFFF"> 
                  <td width="6%"> 
                    <div align="center"><%= incr %></div>
                  </td>
                  <td width="10%"> 
                    <div align="center"> 
                      <input type="checkbox" name="cb<%= incr %>" value="Y" <% if (Receipt.Fields.Item("INVOICENUM").Value<>"")  then response.write "checked"%>>
                    </div>
                  </td>
                  <td width="15%"><%=(Receipt.Fields.Item("RECEIVERNUM").Value)%></td>
                  <td width="15%"><%=(Receipt.Fields.Item("DATERECEIVED").Value)%></td>
                  <td width="15%" align="right"><%=(Receipt.Fields.Item("QTYRECEIVED").Value)%></td>
                  <td width="15%" align="right"><%=(Receipt.Fields.Item("UNITCOST").Value)%></td>
                  <td width="15%" align="right"><%=(Receipt.Fields.Item("LINECOST").Value)%></td>
                </tr>
                <% incr=incr+1
  Repeat4__index=Repeat4__index+1
  Repeat4__numRows=Repeat4__numRows-1
  Receipt.MoveNext()
Wend
%>
              </table>
            </td>
          </tr>
          <tr> 
            <td width="15%">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="4">&nbsp;</td>
          </tr>
          </tbody> 
        </table>
      </form>
    </td>
  </tr>
</table>
</body>
</html>

<%
InvHist.Close()
%>
<%
CompCode.Close()
%>
<%
Acct.Close()
%>
<%
Verification.Close()
%>
<%
Receipt.Close()
%>
<%
EXIREG.Close()
%>
<%
cn.Close
%>